using System.Globalization;
using NUnit.Framework;
using ValidationFramework.Configuration;
using ValidationFramework.Extensions;

namespace ValidationFramework.Tests.Configuration
{
    [TestFixture]
	public class NumberConversionRuleConfigReaderTest
    {

        #region Methods

        [Test]
        public void ReadConfig()
        {
            const string validatorXml = "<rule errorMessage='hello' ruleSet='foo' typeCode='Double' typeName='NumberConversionRule' numberFormatInfoTypeName='System.Globalization.NumberFormatInfo' numberFormatInfoPropertyName='CurrentInfo' numberStyles='AllowDecimalPoint' removeWhiteSpace='true'/>";
            var ruleData = (RuleData.Read(validatorXml.ToXmlReader()));
			var rule = (NumberConversionRule)ConfigurationService.GetRule(ruleData, typeof(string).TypeHandle);
            Assert.AreEqual("hello", rule.ErrorMessage);
			Assert.AreEqual(NumberFormatInfo.CurrentInfo, rule.NumberFormatInfo);
			Assert.AreEqual(NumberStyles.AllowDecimalPoint, rule.NumberStyles);
			Assert.AreEqual(true, rule.RemoveWhiteSpace);

        }

        #endregion


    }
}